import os

import Converters
import Module
import ProjectBase
import Types
import Util


output_cxx_dir = r"D:\CppSource\Temp\Raw\Gen"
output_cxx_ext = ".cxx"

header_wrappers_dir = "{0}{1}Hacks{1}".format(os.path.dirname(__file__), os.path.sep)
header_wrappers_ext = ".pbpp.hpp"

castxml_bin = r'castxml'
_castxml_args = r'--castxml-output=1 -w -x c++ -std=c++14 -D__CASTXML__ -fms-compatibility-version=19 -I"D:\CppSource\Temp\Raw"'


def castxml_args(header_path):
    return _castxml_args


def select_headers(entry_header_path, xml_path):
    return entry_header_path,


class Project(ProjectBase.ProjectBase):
    def __init__(self):
        ProjectBase.ProjectBase.__init__(self, None)

        Converters.add(Converters.StrConv())
        Converters.add(Converters.WcsConv())
        Converters.add(Converters.WstringConv())

        Converters.add(Converters.ListConv(Types.Type(("int",), 0, "FundamentalType")))
        Converters.add(Converters.ListConv(Types.Type(("double",), 0, "FundamentalType")))

        K = Types.Type(("std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t>>",), 0, "Class")
        V = Types.Type(("int",), 0, "FundamentalType")
        Converters.add(Converters.DictConv(K, V))

        Raw = Util.load("Raw")

        self.root_mod = Module.Module(
            "Raw",
             None,
             Raw.RawPythonNamer(),
             Raw.RawHeaderProvider(),
             Raw.RawFlagsAssigner(),
             Raw.RawBlacklist()
        )

        pdl = Raw.ProcessingDoneListener()
        self.root_mod.processing_done_listener = pdl

    def try_update(self):
        Raw, reloaded = Util.load2("Raw")

        if reloaded:
            self.root_mod.update_strategies(
                Raw.RawPythonNamer(),
                Raw.RawHeaderProvider(),
                Raw.RawFlagsAssigner(),
                Raw.RawBlacklist()
            )

            pdl = Raw.ProcessingDoneListener()
            self.root_mod.processing_done_listener = pdl
